package org.rescue.analysis.InterDimension;

import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
import java.util.Set;

import javax.swing.tree.DefaultMutableTreeNode;

import org.rescue.Dag.Concept;
import org.rescue.Dag.DAGNode;

public class DAuxiliaryData {
	
	// Associated background concept distribution
	HashMap<Integer, Integer> bgConcepts;
	public DefaultMutableTreeNode candTree;
	
	public DAuxiliaryData () {
		bgConcepts = new HashMap<Integer, Integer>();
	}

	public void setCandTree (DefaultMutableTreeNode candNode) {
		candTree = candNode;
	}
	
	public DefaultMutableTreeNode getCandTree() {
		return candTree;
	}
	
	public void addBGConcept(int conceptId, int count) {
		if (bgConcepts.containsKey(conceptId)) {
			int cnt = bgConcepts.get(conceptId)+ count;
			bgConcepts.put(conceptId,cnt); 	
		}
		else {
			bgConcepts.put(conceptId,count);
		}
	}
	
	public HashMap<Integer, Integer> cloneBGConcepts() {
		// do shallow copy
		return (HashMap<Integer, Integer>)bgConcepts.clone();
	}
	
	public void printBGConcepts() {
	    System.out.println ("BG Concepts:");
		Set<Map.Entry<Integer,Integer>> entries = bgConcepts.entrySet();
		for(Map.Entry<Integer,Integer> entry : entries) {
		    int key = entry.getKey();
		    int count = entry.getValue();
		    System.out.println (key + " " + count);
		}
	}
}